package com.my.content.utlis;

import android.content.Context;
import android.text.format.DateUtils;
import android.widget.ListView;
import android.widget.ScrollView;

import com.handmark.pulltorefresh.library.ILoadingLayout;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.handmark.pulltorefresh.library.PullToRefreshScrollView;

/**
 * 类描述:
 * 创建人:
 * 创建时间:2016/10/19.
 * 备注:
 */
public class PullToRefreshLableUtils {

    /**
     * 获取刷新显示的布局
     */
    public static void setPullToRefreshListLable(PullToRefreshListView spaceRoomPrListView) {
        // 获取刷新显示的布局
        ILoadingLayout startLoading = spaceRoomPrListView.getLoadingLayoutProxy(
                true, false);
        startLoading.setPullLabel("下拉刷新");// 刚下拉时显示的提示
        startLoading.setRefreshingLabel("正在刷新中...");// 刷新时显示的提示
        startLoading.setReleaseLabel("释放即可刷新");// 下拉达到一定距离时显示的提示

        ILoadingLayout endLoading = spaceRoomPrListView.getLoadingLayoutProxy(false,
                true);
        endLoading.setPullLabel("上拉加载更多");// 刚上拉时显示的提示
        endLoading.setRefreshingLabel("拼命加载中...");// 加载时的提示
        endLoading.setReleaseLabel("释放即可加载更多");// 上拉达到一定距离时显示的提示
    }
    public static void setPullToRefreshScrollLable(PullToRefreshScrollView spaceRoomPrScrollView) {
        // 获取刷新显示的布局
        ILoadingLayout startLoading = spaceRoomPrScrollView.getLoadingLayoutProxy(
                true, false);
        startLoading.setPullLabel("下拉刷新");// 刚下拉时显示的提示
        startLoading.setRefreshingLabel("正在刷新中...");// 刷新时显示的提示
        startLoading.setReleaseLabel("释放即可刷新");// 下拉达到一定距离时显示的提示

        ILoadingLayout endLoading = spaceRoomPrScrollView.getLoadingLayoutProxy(false,
                true);
        endLoading.setPullLabel("上拉加载更多");// 刚上拉时显示的提示
        endLoading.setRefreshingLabel("拼命加载中...");// 加载时的提示
        endLoading.setReleaseLabel("释放即可加载更多");// 上拉达到一定距离时显示的提示
    }

    /**
     * 设置最近刷新时间
     *
     * @param refreshListView
     */
    public static void showListRefreshTime(PullToRefreshBase<ListView> refreshListView, Context context) {
        // 设置最近刷新时间
        String updateTime = DateUtils.formatDateTime(
                context, System.currentTimeMillis(),
                DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE
                        | DateUtils.FORMAT_ABBREV_ALL);
        refreshListView.getLoadingLayoutProxy().setLastUpdatedLabel(
                updateTime);
    }
    public static void showScrollRefreshTime(PullToRefreshBase<ScrollView> refreshScrollView, Context context) {
        // 设置最近刷新时间
        String updateTime = DateUtils.formatDateTime(
                context, System.currentTimeMillis(),
                DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE
                        | DateUtils.FORMAT_ABBREV_ALL);
        refreshScrollView.getLoadingLayoutProxy().setLastUpdatedLabel(
                updateTime);
    }
}
